lexer grammar CSV;
@members {
List<RecognitionException> exceptions = new ArrayList<RecognitionException>();

public List<RecognitionException> getExceptions() {
	return exceptions;
}

@Override
public void reportError(RecognitionException e) {
	super.reportError(e);
	exceptions.add(e);
}
}
@header {
package org.churchillroadpta.csvparser;
}

// $ANTLR src "d:\projects\StudentDirectory\src\org\churchillroadpta\csvparser\CSV.g" 50
NEWLINE	:	'\r'? '\n';

// $ANTLR src "d:\projects\StudentDirectory\src\org\churchillroadpta\csvparser\CSV.g" 52
COMMA	: 	(' '* ',' ' '*);

// $ANTLR src "d:\projects\StudentDirectory\src\org\churchillroadpta\csvparser\CSV.g" 54
QUOTED	: ('"' (options{greedy=false;}: .)+ '"')+
		{
			StringBuilder txt = new StringBuilder(getText());
			// Remove first and last double-quote
			txt.deleteCharAt(0);
			txt.deleteCharAt(txt.length()-1);
			// "" -> "
			int probe;
			while ((probe = txt.lastIndexOf("\"\"")) >= 0) {
				txt.deleteCharAt(probe);
			}
			setText(txt.toString());
		};

// $ANTLR src "d:\projects\StudentDirectory\src\org\churchillroadpta\csvparser\CSV.g" 68
UNQUOTED
	:	~('\r' | '\n' | ',' | '"')+;
